pthyon中原始数据raw data和原始字符串r

来源:互联网 发布:淘宝满返模块怎么设置 编辑:程序博客网 时间:2024/04/30 01:24

<span style="font-size:14px;"></pre><pre name="code" class="python">Python 3.4.2 (v3.4.2:ab2c023a9432, Oct  6 2014, 22:15:05) [MSC v.1600 32 bit (Intel)] on win32Type "copyright", "credits" or "license()" for more information.</span>
<span style="font-size:14px;">>>> str1 = raw_input("input str:")Traceback (most recent call last):  File "<pyshell#8>", line 1, in <module>    str1 = raw_input("input str:")NameError: name 'raw_input' is not defined>>> str1 = input("input str:")input str:i love you>>> print str1SyntaxError: Missing parentheses in call to 'print'>>> print(str1)i love you</span>

raw_input表示输入原始数据

在字符串前面加“r”表示字符串,原始字符串不会把反斜线当做特殊字符,原始字符串每个字符都会和书写方式一致

<span style="font-size:14px;">#在python3.0以后的版本中,raw_input和input合体了,取消raw_input,并用input代替,所以现在的版本input接收的是字符串</span>

 #当M大于有效位的时候,表达式右对齐,当M小于有效位的时候,python编译器会正常输出有效数据



0 0
原创粉丝点击