我有一种情况,我需要用前一行值更新记录。
来源:
|MatId | BaseId |Flag|Pkg1| CS1
--------------------------------
|3001 | 3001 | 1 | 20 | 2 |
|3002 | 3001 | 0 | 15 | 3 |
|3003 | 3001 | 0 | 10 | 4 |
Run Code Online (Sandbox Code Playgroud)
这里 3001( MatID) 和 3001( BaseID) 是相同的所以FLAG =1,只有在下一条记录中BASEID是相同的。输出应仅PKG1是使用当前行值更新的字段。
目标或输出:
|MatId | BaseId|Flag|Pkg1|CS1
------------------------------
|3001 | 3001 | 1 | 20 | 2|
|3002 | 3001 | 0 | 20 | 3|
|3003 | 3001 …Run Code Online (Sandbox Code Playgroud) 我正在尝试这段代码,并在以 lat、lng 和 location 开头的行中出现错误。有人可以帮忙吗?
import urllib.parse
import urllib.request
import json
while True:
address = input('Enter location: ')
if len(address) < 1 : break
serviceurl = 'http://python-data.dr-chuck.net/geojson'
url = serviceurl + '?' + urllib.parse.urlencode({'sensor':'false', 'address': address})
response = urllib.request.urlopen(url)
data = response.readall().decode('utf-8')
js = json.loads(str(data))
if 'status' not in js or js['status'] != 'OK':
print ('==== Failure To Retrieve ====')
print (data)
continue
print (json.dumps(js, indent=4))
lat = js["results"][0]["geometry"]["location"]["lat"]
lng = js["results"][0]["geometry"]["location"]["lng"]
print('lat',lat) #,('lng'),lng
location = js['results'[0]]['formatted_address']
print(location)
Run Code Online (Sandbox Code Playgroud)
谢谢,阿伦
我需要将日期转换为此格式yyyy.mm.dd,我使用以下公式 -
Date curDate = new Date();
out.println(curDate);
String pattern = "yyyy.mm.dd";
DateFormat format1 = new SimpleDateFormat(pattern, Locale.ENGLISH);
String DateToStr = format1.format(curDate);
out.println(DateToStr);
Run Code Online (Sandbox Code Playgroud)
我得到的输出是
curDate - Fri Feb 05 15:21:28 CST 2016
DateToStr - 2016.21.05
Run Code Online (Sandbox Code Playgroud)
我需要代替2016.21.05,它应该是DateToStr - 2016.02.05.
我在这里做错了什么帮忙?
谢谢,阿伦