Pyscript is a library which uses python functions inside JavaScript. What is "Py" stands for? "Python"? YES!!! What is Script? as you know well, guess it... YES!!! it's JavaScript. It is nothing big, It's all just plain JavaScript.
It's easy to install PYSCRIPT with NPM.
$ npm i pyscript-js
Pass PYSCRIPT string and some data. Great! you've got some Python functions.
const py = require("pyscript-js");
let a = py.type("2");
py.print(a);
Download a browser build from the latest release, and use it in a script tag.
<script src="pyscript.js"></script>
<script type="text/javascript">
print("Hello User!") // inspect -> console tab
</script>
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>PyScript.js</title> </head> <body> <!-- Your HTML Code Goes Here --> ... <!-- End --> <!-- Adding Scripts --> <!-- Use it above all the Script Files to make use of python functions -->
<!-- User Defined Scripts / Other Scripts below --> <script src="script.js" charset="utf-8"></script> <script type="text/javascript"> print("Hello User!") // inspect -> console tab </script> </body> </html>
// program to generate fibonacci series up to n terms
// take input from the user
number = int(input('Enter the number of terms: '));
n1 = 0,
n2 = 1,
nextTerm = 0;
print('Fibonacci Series:');
for (let i = 1; i <= number; i++) {
print(n1);
nextTerm = n1 + n2;
n1 = n2;
n2 = nextTerm;
}
Python functions available in JavaScript
Indicates that the functions doesn't support in NodeJs. See Tutorial
The issue tracker is the preferred channel for bug reports, features requests and submitting pull requests.
PYSCIRPT is licensed under the MIT License. Information can found here: MIT.
Become a backend developer click here