当前位置:网站首页>Various programming languages decimal | time | Base64 and other operations of the quick look-up table
Various programming languages decimal | time | Base64 and other operations of the quick look-up table
2022-07-28 06:07:00 【Alex_ z0897】
Switch between languages , At this time, a bad pen is better than a good memory . Sort out the processing of rounding decimals in various languages , String and time are exchanged ,base And so on ,
Round to two decimal places
# js
"12.125".toFixed(2)
#python
print("%.2f" % a)
# mysql
select round(a,2)
#golang
value = math.Trunc(value*1e2+0.500000001) * 1e-2
result, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", value), 64)
#java
BigDecimal value = value1.setScale(2,RoundingMode.HALF_UP)
String to time
# python
datetime.strptime(start_time, "%Y-%m-%d %H:%M")
# java
Date date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(str)
# golang
sd, _ := time.Parse("2006-01-02", start)
Time to string
# python
datetime.strftime()
datetime.now().strftime("%Y-%m-%d %X")
# java
String str = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date);
//LocalDateTime form
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").format(new LocalDateTime());
# golang
time.Now().Format("2006-01-02"),
File transfer base64
# dart(flutter)
var image = File(picPath);
var startDate = new DateTime.now();
List<int> imageBytes = await image.readAsBytes();
var fileBase64 = 'data:image/jpeg;base64,'+base64Encode(imageBytes);
base64 code
# java
Base64.getEncoder().encodeToString((str).getBytes())
base64 decode
# java
Base64.getDecoder().decode(data)
Get the current timestamp
# java
new Date().time();
# golang
timeUnixNano:=time.Now().UnixNano()
# dart
new DateTime.now().millisecondsSinceEpoch
# python
datetime.now().timestamp()
turn 13 A time stamp
# python Version is 2.7.~ The old version
# Current time conversion
struct_time = datetime.now().timetuple()
print(int(round(time.mktime(struct_time)* 1000)))
# String conversion
struct_time = time.strptime("2021-10-15 11:04:19", "%Y-%m-%d %H:%M:%S")
print(int(round(time.mktime(struct_time)* 1000)))
Continuous updating …
边栏推荐
- Invalid packaging for parent POM x, must be “pom“ but is “jar“ @
- 【五】redis主从同步与Redis Sentinel(哨兵)
- 4个角度教你选小程序开发工具?
- 【三】redis特点功能
- 使用pyhon封装一个定时发送邮件的工具类
- Distributed lock redis implementation
- No module named yum
- Create a virtual environment using pycharm
- There is a problem with MySQL paging
- svn incoming内容无法更新下来,且提交报错:svn: E155015: Aborting commit: XXX remains in conflict
猜你喜欢
随机推荐
KubeSphere安装版本问题
Dataset类分批加载数据集
Use Python to encapsulate a tool class that sends mail regularly
高端大气的小程序开发设计有哪些注意点?
tensorboard可视化
Mars number * word * Tibet * product * Pingtai defender plan details announced
It's not easy to travel. You can use digital collections to brush the sense of existence in scenic spots
小程序开发哪家更靠谱呢?
MySQL view, stored procedure and stored function
Pytorch deep learning single card training and multi card training
word2vec和bert的基本使用方法
Single line function, aggregate function after class exercise
NLP中基于Bert的数据预处理
微信小程序开发费用制作费用是多少?
raise RuntimeError(‘DataLoader worker (pid(s) {}) exited unexpectedly‘.format(pids_str))RuntimeErro
接口防重复提交
Regular verification rules of wechat applet mobile number
Idempotent component
幂等性组件
Flink CDC (Mysql为例)









