美文网首页
Python -> JavaScript

Python -> JavaScript

作者: ft207741 | 来源:发表于2018-09-27 14:45 被阅读0次

Menu

  • 变量类型
    • int 和 float > JavaScript
    • list > Array
    • dict > Object
  • input() > prompt()
  • tkinter.messagebox.showinfo() > alert()
  • 内置属性 如:len("python") > 全局对象
  • 方法 如:“spam”.index("a") > 包装对象


input() > prompt()

name = input('What is your name?')
var name = prompt('What is your name?');

tkinter.messagebox.showinfo() > alert()

import tkinter.messagebox
tkinter.messagebox.showinfo("show info", "nice to see you!")
alert('Nice to see you!'); 

变量类型:

  • int 和 float > Number

  • list > Array

  • dict > Object


  • 内置属性 如:len("python") > 全局对象
  • 方法 如:“spam”.index("a") > 包装对象

bin() > toString(2)
oct() > toString(8)
hex() > toString(16)

var n = 123456.789;
n.toFixed(0); // "123457"
n.toFixed(2); // "123456.79"
n.toFixed(5); // "123456.78900"

document.write(parseFloat("1.234word")) // 1.234
document.write(parseInt("1.234word")) // 1
document.write(Number("1.234word")) // NaN



相关文章

网友评论

      本文标题:Python -> JavaScript

      本文链接:https://www.haomeiwen.com/subject/wcxeoftx.html