//save data
private void writeNewUser(string userId, string name, string email)
{
User user = new User(name, email);
string json = JsonUtility.ToJson(user);
//save user data with json
mDatabaseRef.Child("users").Child(userId).SetRawJsonValueAsync(json);
//save time
mD
如何将for loop中的结果保存到variable中?基本上,在这个例子中,print所做的是:
myList = ['a' ,'b' , 'c' , 'd' , 'e']
for i in myList:
print i
结果:
>>>
a
b
c
d
e
>>>
我想将这个打印结果准确地保存到一个变量中。
直到现在我才像这样解决了它:
myList = ['a' ,'b' , 'c' , 'd' ,
因此,我试图从包含大量字典的列表中提取数据。具体来说,这两个键都是:第一字典中的值对,只有。例如,最终目标是将‘符号’保存到变量,'AAPL'保存到变量(如果可能的话)。下面是我到目前为止要提取整个列表的代码:
from urllib.request import urlopen
import json
with urlopen("https://financialmodelingprep.com/api/v3/ratios/AAPL?apikey=MYAPIKEY") as response:
source = response.read()
当我使用JSON.dump()时,我的格式低于JSON格式
Dumps data"b'{\"AutomaticReadabilityIndex\":2.7999999999999994,\"AgeLevel\":[\" 11 to 12\"],\"Statement\":[\"Nice. Your grade is about six\"],\"SpacheScore\":1.877,\"GunningFogScore\":9.099999999999998,\
在下面的构造中,我试图通过我的web服务传递一个JSON对象。作为一个新需求,我必须传递一个字典对象,该对象在下面的代码中为sent。您能指导我如何将字典添加到JSON对象中吗?
if plain_text is not None:
blob = TextBlob(plain_text)
sentiment = TextBlob(plain_text)
sent = {}
for sentence in blob.sentences:
sent[sentence] =sentence.sentiment.p