我想使用以下代码在python中拆分一个字符串:
means="a ? b ? c"
lst=means.split("?")
Run Code Online (Sandbox Code Playgroud)
但我收到此错误消息:
SyntaxError:第2行文件dict.py中的非ASCII字符'\ xd8',但未声明编码; 有关详细信息,请参阅http://www.python.org/peps/pep-0263.html
如何声明编码?
我有使用问题struct在Ç语言.
这很奇怪!!!
我不能course在studentstruct中使用struct.
我以前定义过它但是......为什么?
struct course
{
int no;
char name[30];
int credits;
float score;
};
struct student
{
int no;
char name[50];
course c[3];
};
Run Code Online (Sandbox Code Playgroud)
我的语言是C ^不是C++
我在Python集中插入变量有问题.有谁知道我得到了什么: s.insert(len(s),x)?
我的问题是当我想在一个集合或列表中插入或添加 x时.
为什么我不能这样做?以及如何解决这个问题?
我的代码:
import nltk
import Set
FILE=open("out.txt", "w")
FILE.writelines("this is to show why using NNs :)!!!!\n")
text1=raw_input()
FILE.writelines("first text loaded.....\n")
sentences1=text1.split('.')
FILE.writelines("first text splited.....\n")
text2=raw_input()
FILE.writelines("second text loaded.....\n")
sentences2=text2.split('.')
FILE.writelines("second text splited.....\n")
s=['a','b']
FILE.writelines("\n NNs for first:\n")
for sen in sentences1:
tokens1= nltk.word_tokenize(sen)
tagged1 = nltk.pos_tag(tokens1)
for (x, y) in tagged1:
if y=='NN':
FILE.writelines(x+",")
s.insert(len(s),x)
FILE.writelines(len(s1))
FILE.writelines("\n NNs for second:\n")
for sen in sentences2:
tokens2= nltk.word_tokenize(sen)
tagged2 = nltk.pos_tag(tokens2)
for (x, y) …Run Code Online (Sandbox Code Playgroud)