{"rsdb":{"rid":"241553","subhead":"","postdate":"0","aid":"166328","fid":"77","uid":"1","topic":"1","content":"
\n

\u4e00\u3001print<\/h2> \n

\u5728 python<\/a>2 \u4e2d print \u662f\u4e00\u6761\u8bed\u53e5\uff0c\u800c\u5728 python<\/a>3 \u4e2d print \u4f5c\u4e3a\u51fd\u6570\u5b58\u5728\u3002<\/p> \n

\n
# python2\n>>> print ("hello")\nhello\n\n# python3 \n>>> print ("hello")\nhello\n<\/pre> \n <\/div> \n 

 <\/p> \n

\u8fd9\u6837\u770b\u597d\u50cf\u6ca1\u6709\u4ec0\u4e48\u533a\u522b\uff0cpython2 \u597d\u50cf\u4e5f\u53ef\u4ee5\u628a print \u5f53\u505a\u51fd\u6570\u4f7f\u7528\uff0c\u4f46\u662f\u4ec5\u4ec5\u662f\u8868\u8c61\u800c\u5df2\uff0c\u524d\u8005\u662f\u628a ("hello")\u5f53\u4f5c\u4e00\u4e2a\u6574\u4f53\uff0c\u800c\u540e\u8005 print()\u662f\u4e2a\u51fd\u6570\uff0c\u63a5\u6536\u5b57\u7b26\u4e32\u4f5c\u4e3a\u53c2\u6570\u3002<\/span><\/p> \n

\n
#python2\n>>> print ("hello","world")\n('hello', 'world')\n\n#python3\n>>> print ("hello","world")\nhello world\n<\/pre> \n <\/div> \n 

 <\/p> \n

\u8fd9\u6837\u770b\u5c31\u975e\u5e38\u660e\u663e\u4e86\uff0cpython2 \u4e2d\uff0cprint \u8bed\u53e5\u540e\u63a5\u7684\u662f\u5143\u7ec4\u5bf9\u8c61 ("hello","world")\u3002<\/p> \n

\u800c python3 \u4e2d\uff0cprint() \u51fd\u6570\u662f\u5f97\u5230\u4e86\u4e24\u4e2a\u4f4d\u7f6e\u53c2\u6570 hello \u548c world \u3002<\/p> \n

\u5982\u679c\u60f3\u5728 python2 \u4e2d\u628a print \u5f53\u505a\u51fd\u6570\u4f7f\u7528\uff0c\u53ef\u4ee5\u5bfc\u5165 __future__ \u6a21\u5757\u4e2d\u7684 print_function<\/p> \n

\n
>>> print ("Hello","world")\n('Hello', 'world')\n>>> \n>>> from __future__ import print_function\n>>> print ("Hello","world")\nHello world\n<\/pre> \n <\/div> \n 

 <\/p> \n

 \u4e8c\u3001\u7f16\u7801<\/h2> \n

python2 \u9ed8\u8ba4\u7f16\u7801\u662f asscii\uff0c\u6240\u4ee5\u4e0d\u80fd\u76f4\u63a5\u6253\u5370\u4e2d\u6587\uff0c\u5982\u679c\u8981\u5728\u811a\u672c\u4e2d\u4f7f\u7528\u4e2d\u6587\uff0c\u9700\u8981\u5728\u811a\u672c\u4e2d\u58f0\u660e\u4f7f\u7528utf-8\uff0c# -*- coding: utf-8 -*-\uff0c<\/p> \n

\n
#!\/usr\/bin\/env python\n# -*- coding: utf-8 -*-\nprint "\u60a8\u597d"\n<\/pre> \n <\/div> \n 

 <\/p> \n

\u800c\u5728 python3 \u4e2d\uff0c\u9ed8\u8ba4\u7f16\u7801\u5df2\u7ecf\u662f utf-8 \u4e86\uff0c\u6240\u4ee5\u5df2\u7ecf\u4e0d\u9700\u8981\u5355\u72ec\u58f0\u660e\u4e86\uff0c\u53ef\u4ee5\u76f4\u63a5\u6253\u5370\u4e2d\u6587\u5185\u5bb9\u3002<\/p> \n

\n
#!\/usr\/bin\/env python\nprint ("\u60a8\u597d")\n<\/pre> \n <\/div> \n 

 <\/p> \n

 \u4e09\u3001\u7528\u6237\u8f93\u5165<\/h2> \n

python 2 \u7528\u6237\u8f93\u5165\u4f7f\u7528 raw_input()\uff0cpython 3 \u4f7f\u7528 input()\uff0cpython2 \u4e2d\u4e5f\u53ef\u4ee5\u4f7f\u7528 input()\uff0c\u4f46\u662f\u53c2\u6570\u53ea\u80fd\u662f\u53d8\u91cf\uff0c\u4e0d\u63a8\u8350\u5728python 2 \u4e2d\u4f7f\u7528 input()\u3002<\/p> \n

\n
#!\/usr\/bin\/env python\n\n#user_input = raw_input("Please input something: ") #only on python 2.x\nuser_input = input("Please input something: ")\nprint(user_input)\n<\/pre> \n <\/div> \n 

 <\/p>\n<\/div>","orderid":"0","title":"Python2\u548c3\u7684\u4e3b\u8981\u533a\u522b","smalltitle":"","mid":"0","fname":"Python","special_id":"0","bak_id":"0","info":"0","hits":"110","pages":"1","comments":"0","posttime":"2017-11-23 08:31:42","list":"1511397102","username":"admin","author":"","copyfrom":"","copyfromurl":"","titlecolor":"","fonttype":"0","titleicon":"0","picurl":"https:\/\/www.cppentry.com\/upload_files\/","ispic":"0","yz":"1","yzer":"","yztime":"0","levels":"0","levelstime":"0","keywords":"Python2<\/A> \u4e3b\u8981<\/A> \u533a\u522b<\/A>","jumpurl":"","iframeurl":"","style":"","template":"a:3:{s:4:\"head\";s:0:\"\";s:4:\"foot\";s:0:\"\";s:8:\"bencandy\";s:0:\"\";}","target":"0","ip":"14.20.31.236","lastfid":"0","money":"0","buyuser":"","passwd":"","allowdown":"","allowview":"","editer":"","edittime":"0","begintime":"0","endtime":"0","description":"Python2\u548c3\u7684\u4e3b\u8981\u533a\u522b","lastview":"1702196624","digg_num":"0","digg_time":"0","forbidcomment":"0","ifvote":"0","heart":"","htmlname":"","city_id":"0"},"page":"1"}