$ python Python 2.6.4 (#1, Nov 11 2014, 13:34:43) [GCC 4.1.2 20120704 (Red Hat 5.6.2-48)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>>
>>> print "Hello, Python!";
Hello, Python!
print "Hello, Python!";
$ python test.py
Hello, Python!
#!/usr/bin/python print "Hello, Python!";
$ chmod +x test.py # This is to make file executable $./test.py
Hello, Python!
if True: print "True" else: print "False"
if True: print "Answer" print "True" else: print "Answer" print "False"
#!/usr/bin/python
import sys
try:
# open file stream
file = open(file_name, "w")
except IOError:
print "There was an error writing to", file_name
sys.exit()
print "Enter '", file_finish,
print "' When finished"
while file_text != file_finish:
file_text = raw_input("Enter text: ")
if file_text == file_finish:
# close the file
file.close
break
file.write(file_text)
file.write("\n")
file.close()
file_name = raw_input("Enter filename: ")
if len(file_name) == 0:
print "Next time please enter something"
sys.exit()
try:
file = open(file_name, "r")
except IOError:
print "There was an error reading file"
sys.exit()
file_text = file.read()
file.close()
print file_text
total = item_one + \
item_two + \
item_three
days = ['Monday', 'Tuesday', 'Wednesday',
'Thursday', 'Friday']
word = 'word' sentence = "This is a sentence." paragraph = """This is a paragraph. It is made up of multiple lines and sentences."""
#!/usr/bin/python # First comment print "Hello, Python!"; # second comment
Hello, Python!
name = "Madisetti" # This is again comment
# This is a comment. # This is a comment, too. # This is a comment, too. # I said that already.
#!/usr/bin/python
raw_input("\n\nPress the enter key to exit.")
import sys; x = 'foo'; sys.stdout.write(x + '\n')
if expression : suite elif expression : suite else : suite
$ python -h usage: python [option] ... [-c cmd | -m mod | file | -] [arg] ... Options and arguments (and corresponding environment variables): -c cmd : program passed in as string (terminates option list) -d : debug output from parser (also PYTHONDEBUG=x) -E : ignore environment variables (such as PYTHONPATH) -h : print this help message and exit [ etc. ]
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有