本文摘自php中文网,作者黄舟,侵删。
这篇文章主要介绍了Python原始字符串与Unicode字符串操作符用法,结合实例形式分析了Python针对原始字符与Unicode字符的操作符用法,需要的朋友可以参考下本文实例讲述了Python原始字符串与Unicode字符串操作符用法。分享给大家供大家参考,具体如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | import re
def originalOper():
print "\n"
print r "\n"
try :
testFile = open (r "E:\PythonDemo\CorePythonBook2\output" , "r" )
for line in testFile.readlines():
line = "%r" % line
m = re.search(r "\\[rn]" ,line)
if m is not None :
print line
except Exception,e:
print e
finally :
testFile.close()
def unicodeOper():
print u "abc"
print u "\u1234"
print u "abc\u1234\n"
print ur "Hello\nWorld!"
originalOper()
unicodeOper()
|
运行结果如下:

以上就是关于Python中原始字符串与Unicode字符串操作符的实例的详细内容,更多文章请关注木庄网络博客!!
相关阅读 >>
为什么黑客都用Python
Python的浮点数占多少个字节
Python 2.7与Python 3.7区别
Python如何实现excel多表合并(附代码)
用Python画月亮的代码是什么?
Python如何把数字变成日期
Python有什么好书推荐
Python批量读取图片且存入数据库的实现
最详细的Python库总结
pickle库的使用详解
更多相关阅读请进入《Python》频道 >>
人民邮电出版社
python入门书籍,非常畅销,超高好评,python官方公认好书。
转载请注明出处:木庄网络博客 » 关于Python中原始字符串与Unicode字符串操作符的实例