09 2011 档案
摘要:在打开文件的时候open(r'c:\....')加r和不加''r是有区别的'r'是防止字符转义的 如果路径中出现'\t'的话 不加r的话\t就会被转义 而加了'r'之后'\t'就能保留原有的样子在字符串赋值的时候 前面加'r'可以防止字符串在时候的时候不被转义 原理是在转义字符前加'\'例:s=r'\tt'print(s)Output:'\tt's='\tt'print(s)Output:' t'
阅读全文
摘要:忘记里给改过的字符替换掉 自己没有想到两个端点如果中间容纳不下3个字符的时候输出0 后来看了别人的代码 改过这两处才对 GPandaDescriptionWhen I wrote down this letter, you may have been on the airplane to U.S.We have known for 15 years, which has exceeded one-fifth of my whole life. I still remember the first time we went to the movies, the first time we wen
阅读全文
摘要:把皇后这个经典的问题早就听说过 但是一直没自己去实现过 这次学习Python的时候用Pyhon实现了一下 代码是来自看的书上的def conflict(state,nextX): nextY=len(state) for i in range(nextY): if abs(state[i]-nextX) in (0,nextY): return True return Falsedef queens(num=8,state=()): for pos in range(num): if not conflict(state,pos): if len(state)==num-1: ...
阅读全文

浙公网安备 33010602011771号