我是靠谱客的博主 害羞黄豆,最近开发中收集的这篇文章主要介绍"/usr/local/lib/python3.5/dist-packages/fastai/structured.py", line 34,觉得挺不错的,现在分享给大家,希望可以做个参考。
概述
运行如下代码
from fastai.imports import *
from fastai.structured import *
报错
File "<ipython-input-1-7b88e6cf1f4f>", line 26, in <module>
from fastai.structured import *
File "/usr/local/lib/python3.5/dist-packages/fastai/structured.py", line 34
('Tree {',f'Tree {{ size={size}; ratio={ratio}', s)))
^
SyntaxError: invalid syntax
解决方案:
查看函数re.sub的使用方法
re.sub
re.sub用于替换字符串中的匹配项。下面一个例子将字符串中的空格 ’ ’ 替换成 ‘-’ :
import re
text = ”JGood is a handsome boy, he is cool, clever, and so on…”
print re.sub(r‘s+’, ‘-‘, text)
re.sub的函数原型为:re.sub(pattern, repl, string, count)
其中第二个函数是替换后的字符串;本例中为’-‘
第四个参数指替换个数。默认为0,表示每个匹配项都替换。
将‘f’去掉,加上‘r’,就解决了。
(r'Tree {','Tree {{ size={size}; ratio={ratio}', s)))
最后
以上就是害羞黄豆为你收集整理的"/usr/local/lib/python3.5/dist-packages/fastai/structured.py", line 34的全部内容,希望文章能够帮你解决"/usr/local/lib/python3.5/dist-packages/fastai/structured.py", line 34所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复