这是我的代码:
1号座
import requests
import pandas as pd
url = ('http://www.omdbapi.com/' '?apikey=ff21610b&t=social+network')
r = requests.get(url)
json_data = r.json()
# from app
print(json_data['Awards'])
json_dict = dict(json_data)
tab=""
# printing all data as Dictionary
print("JSON as Dictionary (all):\n")
for k,v in json_dict.items():
if len(k) > 6:
tab = "\t"
else:
tab = "\t\t"
print(str(k) + ":" + tab + str(v))
df = pd.DataFrame(json_dict)
df.drop_duplicates(inplace=True)
# printing Pandas DataFrame of all data
print("JSON as DataFrame (all):\n{}".format(df))
Run Code Online (Sandbox Code Playgroud)
我只是在 DataCamp 上测试一个示例问题。然后我开始探索不同的事情。问题停在print(json_data['Awards'])。我进一步测试将 JSON 文件转换为字典并创建它的 …
我正在Windows 10的5.1版中编写PowerShell脚本,该脚本可获取有关本地系统(最终是其子网)的某些信息,并将其输出到文本文件中。首先,我将所有方面都集成到一个函数中。我在输出getUsersAndGroups和getRunningProcesses函数时遇到输出问题,其中的输出getUsersAndGroups将注入到的输出中getRunningProcesses。
这两个功能是:
# Powershell script to get various properties and output to a text file
Function getRunningProcesses()
{
# Running processes
Write-Host "Running Processes:
------------ START PROCESS LIST ------------
"
Get-Process | Select-Object name,fileversion,productversion,company
Write-Host "
------------- END PROCESS LIST -------------
"
}
Function getUsersAndGroups()
{
# Get Users and Groups
Write-Host "Users and Groups:"
$adsi = [ADSI]"WinNT://$env:COMPUTERNAME"
$adsi.Children | where {$_.SchemaClassName -eq 'user'} | Foreach-Object {
$groups = $_.Groups() | …Run Code Online (Sandbox Code Playgroud)